package com.iot.http2.service.impl;

import com.iot.http2.entity.DemoEntity;
import com.iot.http2.service.BusinessService;
import com.iot.http2.service.InnerService;
import com.iot.http2.utils.DemoUtil;
import com.iot.http2.vo.DemoDTO;
import com.iot.http2.vo.DemoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 业务服务
 * @author guoguoqiang
 * @date 2020-11-26
 * @since 2020-11-26
 */
@Service
public class BusinessServiceImpl implements BusinessService {
    private InnerService innerService;

    private String name;

    public BusinessServiceImpl() {
    }

    public BusinessServiceImpl(String name) {
        this.name = name;
    }

    @Autowired
    public BusinessServiceImpl(InnerService innerService) {
        this.innerService = innerService;
    }

    @Override
    public String hello(String name) {
        return "hello:" + name;
    }

    @Override
    public String callInner(String name) {
        return innerService.inner1(name);
    }

    @Override
    public DemoEntity findById(Long id) {
        return DemoEntity.builder().name("real findById:" + id).build();
    }

    @Override
    public String demoUtil(String name) {
        return DemoUtil.demoMethod(name);
    }

    @Override
    public DemoVO callInner12(DemoDTO dto) {
        return innerService.callInner2(dto);
    }

    @Override
    public String noMockMe(String name) {
        return "no mock me:" + name;
    }

    public void setInnerService(InnerService innerService) {
        this.innerService = innerService;
    }
}
